# 第一题、用类封装一个MyMath类, 实现加, 减, 乘, 除, 幂, 开方
class ParamsError(object):
    pass


class MyMath:
    def add(self, a, b):
        return a + b

    def sub(self, a, b):
        return a - b

    def mul(self, a, b):
        return a * b

    def div(self, a, b):
        try:
            return a / b
        except ZeroDivisionError:
            raise ParamsError("除法中，分母不能为0")
        finally:
            print('div None')

    def remainder(self, a, b):
        return a ** b

    def sqare(self, a, b):
        return a ** b

math = MyMath()
print(math.add(1, 2))
print(math.sub(4, 2))
print(math.mul(1, 2))
print(math.div(4, 2))
print(math.remainder(2, 4))
print(math.sqare(4, 1/2))

# 第二题、自由课题, 大家按自己的想法, 将身边的事物抽象出一个类, 并创建多个实例
class Cup(object):
    subject = 'cup'

    def __init__(self, obj):
        self.obj = obj

# 第三题、创建多个继承作业2父类的子类
class GlassCup(Cup):
    materail = 'glass'


class PlasticCup(Cup):
    materail = 'plastic'


A_Cup = GlassCup("玻璃杯")
B_Cup = PlasticCup("塑料杯")
print(A_Cup.materail)
print(B_Cup.materail)

